#ifndef __MY_I2C_H
#define __MY_I2C_H

#include "driver/i2c.h"
#include "driver/gpio.h"

#define Master_PORT    I2C_NUM_1 //主机端口设置
#define Master_SDA_NUM 32        //主机SDA引脚设置
#define Master_SCL_NUM 33        //主机SCL引脚设置
#define Master_SPEED   100000     //主机模式时钟频率设置,不高于1MHz
//#define Device_Address 0x28

extern SemaphoreHandle_t I2C_Mutex;     //递归互斥信号量

esp_err_t MY_I2C_Master_Init(void);
esp_err_t MY_I2C_Write_Byte(uint8_t addr, uint8_t reg, uint8_t data);
esp_err_t MY_I2C_Write_Len(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *data);
esp_err_t MY_I2C_Read_Byte(uint8_t addr, uint8_t reg, uint8_t *res);
esp_err_t MY_I2C_Read_Len(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf);
#endif

